<template>
  <div class="shop-wapper" v-if="shop.shopIcon">
    <div class="shop-container">
      <div class="shop-title">
        <div class="left"><img :src="shop.shopIcon" class="icon" /></div>
        <div class="right">
          <span class="name">{{shop.shopName}}</span>
          <span class="crediticon"><img :src="shop.creditLevelIcon" class="icon" /></span>
        </div>
      </div>
      <div class="shop-evaluate">
        <div v-for="(item, index) in shop.evaluates"
          :key="index" class="item">{{item.title}} {{item.score}}</div>
      </div>
    </div>
  </div>
</template>

<script>
  import { getProductDetail } from 'api/product';

  export default {
    name: 'ProductShop',
    props: {
      productId: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        shop: ''
      };
    },
    created() {
      this.getDetail(this.productId).then(() => {
        this.$emit('loaded');
      });
    },
    methods: {
      getDetail(id) {
        return getProductDetail(id).then(data => {
          this.shop = data.data.seller;
        });
      }
    }
  };
</script>

<style lang="scss" scoped>
@import "~assets/scss/mixins";
  .shop-wapper {
    width: 100%;
    background-color: #fff;
    margin-top: 10px;
  }

  .shop-wapper .shop-container {
    padding: 0 10px;
    width: 100%;
  }

  .shop-wapper .shop-title {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .shop-wapper .shop-title .left {
    width: 50px;
    height: 50px;
  }

  .shop-wapper .shop-title .left .icon {
    overflow: hidden;
    width: 100%;
    height: 100%;
  }

  .shop-wapper .shop-title .right {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    padding-left: 10px;
  }

  .shop-wapper .shop-title .right .name {
    font-size: 14px;
    padding-bottom: 5px;
  }

  .shop-wapper .shop-title .right .crediticon {
    display: inline-block;
    height: 14px;
  }

  .shop-wapper .shop-title .right .crediticon .icon {
    overflow: hidden;
    height: 100%;
  }

  .shop-wapper .shop-evaluate {
    @include flex-around();
    color: #999;
    padding-bottom: 20px;
  }
</style>
